package world.criver.h50529.application;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import world.criver.h50529.controller.conStartInform;

import java.util.Timer;
import java.util.TimerTask;

public class appStartInform extends Application
{
    private boolean is_green=false;
    private String message;
    public appStartInform(String me,boolean ok){
        is_green=ok;
        message=me;
    }
    @Override
    public void start(Stage stage) throws Exception {
        FXMLLoader loader=new FXMLLoader(appStartInform.class.getResource("/world/criver/h50529/fxml/startInform.fxml"));
        Scene sc=new Scene(loader.load());
        sc.setFill(null);
        conStartInform con=loader.getController();
        con.light.setStyle("-fx-background-color: "+(is_green?"green":"red"));
        con.tip.setText(message);
        stage.setScene(sc);
        stage.initStyle(StageStyle.TRANSPARENT);
        Stage parent=new Stage();
        parent.initStyle(StageStyle.UTILITY);
        parent.setOpacity(0);
        parent.show();
        stage.initOwner(parent);
        stage.show();

        stage.setX(Screen.getPrimary().getVisualBounds().getWidth()-stage.getWidth());
        stage.setY(Screen.getPrimary().getVisualBounds().getHeight()-stage.getHeight());
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                Platform.runLater(()->{
                    stage.hide();
                    parent.hide();
                });
            }
        },2000);
    }
}
